﻿using Microsoft.EntityFrameworkCore;

namespace Devonline.AspNetCore;

/// <summary>
/// 附加信息类服务
/// 每个 TEntitySet 类型中的 TAdditional 类型的附加信息认为有且仅有一个
/// </summary>
/// <typeparam name="TDbContext">数据库上下文</typeparam>
/// <typeparam name="TAdditional">附加信息数据类型</typeparam>
/// <typeparam name="TKey">键类型</typeparam>
public interface IAdditionalService<TDbContext, TAdditional, TKey>
    where TDbContext : DbContext
    where TAdditional : class, IAdditional<TKey>
    where TKey : IConvertible
{
    /// <summary>
    /// 新增业务数据的附加信息
    /// </summary>
    /// <param name="additionals">附加数据集合</param>
    /// <param name="additionalId">业务数据主键</param>
    /// <returns></returns>
    Task AddAdditionalsAsync(IEnumerable<TAdditional>? additionals, TKey additionalId);
    /// <summary>
    /// 更新业务数据的附加信息
    /// </summary>
    /// <param name="additionals">附加数据集合</param>
    /// <param name="additionalId">业务数据主键</param>
    /// <returns></returns>
    Task UpdateAdditionalsAsync(IEnumerable<TAdditional>? additionals, TKey additionalId);
    /// <summary>
    /// 删除业务数据的附加信息
    /// </summary>
    /// <param name="additionalId">业务数据主键</param>
    /// <returns></returns>
    Task DeleteAdditionalsAsync(TKey additionalId);
}